package cn.itheima.task;

import java.io.*;
import java.util.*;

public class Demo1 {
    public static void main(String[] args) throws IOException {
        //使用bw将文章按照\r\n一个一个的分割成字符串对象，存入集合中

        BufferedReader br = new BufferedReader(new FileReader("D:\\com\\com.txt"));
        TreeMap<Integer,String> map = new TreeMap<>();
        char[] chars = new char[1024];
        String  len ;
        while ((len=br.readLine())!=null){
            len = len.trim();
            String[] split = len.split("\\.");
            int num = 0;
            try {
                num = Integer.parseInt(split[0]);
            } catch (NumberFormatException e) {
                num = Integer.parseInt(split[0].substring(1,2));
                //System.out.println(Arrays.toString(split));
            }
            map.put(num,split[1]);
        }

        br.close();
        BufferedWriter bw = new BufferedWriter(new FileWriter("D:\\com\\demo1.txt"));
        for (Map.Entry<Integer, String> mp: map.entrySet()){
            bw.write(mp.getKey()+"."+mp.getValue());
            bw.newLine();
        }
        bw.close();
    }
}
